﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using PBOffice.BLL;
using PBOffice.DAL;
using System.Web.UI.HtmlControls;

public partial class ScheduleManager : System.Web.UI.Page
{

   
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    //绑定农历时间和小图标
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        User user = (User)Session["userManage"];
        string strReqTime = "";
        CalendarDay cd = ((DayRenderEventArgs)e).Day;//自定义显示内容
        TableCell tc = ((DayRenderEventArgs)e).Cell;//获取表示呈现在控件中的单元格
        strReqTime = "<br><br>" + showTime(cd.Date);

        if (e.Day.IsOtherMonth == true)
        {
            e.Cell.Controls.Clear();
        }
        else
        {
            HyperLink link = new HyperLink();
            link.ImageUrl = "~/images/file/add_Schedule.gif";
            link.NavigateUrl = "SaveMySchedule.aspx?day=" + cd.Date.ToShortDateString();
            Literal li = new Literal();
            li.Text = "&nbsp;&nbsp;";
            tc.Controls.Add(li);
            tc.Controls.Add(link);
            Label lable = new Label();
            lable.Text = strReqTime;
            tc.Controls.Add(lable);

            MyScheduleBLL sch = new MyScheduleBLL();
            List<v_DepUserSch> schInfor = sch.ShowSchedule(user.UserNo,cd.Date);
            foreach (var item in schInfor)
            {
                if (item.SchNo!= 0)
                {
                    HtmlAnchor ha = new HtmlAnchor();
                    ha.InnerText = "◎" + item.SchTopic;
                    ha.HRef = "SaveMySchedule.aspx?day=" + cd.Date.ToShortDateString();
                    ha.Attributes.Add("style","text-decoration:none");
                    tc.Controls.Add(new LiteralControl("&nbsp;" + "&nbsp;" + "&nbsp;"));
                    tc.Controls.Add(new LiteralControl("<br>"));
                    tc.Controls.Add(ha);
                    tc.Controls.Add(new LiteralControl("<br>"));
                };
            }
        }
    
    }
    //转农历的公共方法
    private static ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
    private static string showTime(DateTime mm)
    {
        string[] day = new string[] { "*","初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十" };
        string[] month = new string[] { "*", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊" };
        int n = chineseDate.GetDayOfMonth(mm);
        int m = chineseDate.GetMonth(mm);
        if (m == 13)
            m = 1;
        return month[m]+"月"+day[n];
    }
 

}

